<?php
require_once("../includes/Includes.php");
require_once("../includes/User_type.class.php");

if(!$session->is_logged_in())
    {
     //header("Location: login.php");
    }
	
$email = $_POST["email"];
$password = $_POST["password"];

if(($email=="") || ($password == ""))
    {
	 echo "PLZ Enter compete data .";
    }
else
    {
     $found_user = User::authenicate($email , $password);
     if ($found_user)
        {   
	     $session->login($found_user);
		 if(User_type::find_type_name($found_user->get_user_type())=="admin")
		 {
             header("Location: ../admin/faculty_home.php");
		 }
		 else if ((User_type::find_type_name($found_user->get_user_type()) == "doctor") || (User_type::find_user_type_name($found_user->get_user_type()) == "teacher") )
		 {
		    header("Location: ../staff/staff_home.php");
		 }
		 else if (User_type::find_type_name($found_user->get_user_type())=="student")
		 {
		      header("Location: ../student/student_home.php");
		 }
		}
     else
		{
         $message="Username/password combination incorrect.";
	     echo $message . "<br/> <br/>" ;
	     //include("home.php");
        }
    }
?>